package concurrent.tool;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class CallableFureTest2 {

	public static void main(String[] args) throws ExecutionException, InterruptedException {
		
		System.out.println("开始。。。");
		
		//在其他线程执行耗时任务
		ExecutorService serivce = Executors.newSingleThreadExecutor(); //ExecutorService继承自Executor
		Future<Double> future = serivce.submit(new MyCallable());
		
		Thread.sleep(3000); //代表要做一些其他的操作
		System.out.println("主线程执行完毕");
		
		System.out.println(future.get());
	}
}
